package mine.activity;

import android.app.Service;
import android.os.Bundle;
import android.os.Vibrator;
import android.widget.TextView;

import com.orm.SugarRecord;
import com.whu.administrator.ws.R;
import com.whu.administrator.ws.UIHandler;

import model.BeiWang;

/**
 * Created by Administrator on 2016/3/23.
 */
public class Alarm extends UIHandler.BaseActivity {

    TextView tv_time;
    TextView tv_content;

    String time;
    BeiWang beiWang;

    Vibrator vib ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alarm);
        initview();
        initdata();
    }

    private void initdata() {
        Long id = getIntent().getLongExtra("id",0);
        if (id == 0)
        {
            finish();
            return;
        }
        beiWang = SugarRecord.findById(BeiWang.class,id);
        if (beiWang == null)
        {
            finish();
            return;
        }
        tv_time.setText(beiWang.getTime());
        tv_content.setText(beiWang.getContent());

        vib = (Vibrator) this.getSystemService(Service.VIBRATOR_SERVICE);
        vib.vibrate(new long[]{100,10,100,1000,100,10,100,1000}, -1);

    }

    private void initview() {
        tv_time = (TextView) findViewById(R.id.id_tv_time);
        tv_content = (TextView) findViewById(R.id.id_tv_content);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (vib != null)
            vib.cancel();
    }
}
